package 力扣日常刷题.木22二月.第06天212;

import java.util.PriorityQueue;

/**
 * @author 帅小伙
 * @date 2022/2/12
 * @description
 */
public class Demo51JZ最小的k个数 {

    public int[] getLeastNumbers(int[] arr, int k) {
        int[] res=new int[k];
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        for (int i : arr) {
            priorityQueue.add(i);
        }
        for (int i = 0; i < res.length; i++) {
            res[i] = priorityQueue.poll();
        }
        return res;
    }

}
